home *** CD-ROM | disk | FTP | other *** search
/ PC for Alla 2005 May / PC för Alla 0505.iso / fullversioner / realsoft3d / data1.cab / Scripting / scripts / js / myclasses / toolbars / mytoolbar.js < prev    next >
Encoding:
Text File  |  2005-04-04  |  2.0 KB  |  81 lines

  1.  
  2. //
  3. // Description:
  4. //      Sample Tool Bar class. Implements basic functionality for all toolbars.
  5. //      Creates a window with a horizontal or vertical packer. Defines method 'AddTool'
  6. //      which allows derived classes to insert tool buttons + associated callbacks
  7. //      easily. 
  8. //
  9. // Super class:
  10. //      oops/r3window.js
  11. //
  12. // Constructor:
  13. //      toolbar = new myToolbar(String name, Integer Orientation);
  14. //
  15. // Methods:
  16. //      AddTool(String name, function callback);
  17. //
  18.  
  19. include("oops/r3button.js");
  20. include("oops/r3window.js");
  21. include("oops/r3packer.js");
  22.  
  23. // Orientation codes
  24.  
  25. var VERTICAL = R3PAOF_VERTICAL;
  26. var HORIZONTAL = R3PAOF_HORIZONTAL;
  27.  
  28.  
  29. // method for adding tools
  30.  
  31. function mytbAddTool(text, callback)
  32. {
  33.     // create a button with given label
  34.     button = new r3Button(R3RA_Hook, callback,
  35.                           R3WGA_Parent, this,
  36.                           R3GA_Text, text);
  37.                           
  38.     if(button) {
  39.         // insert the button into the packer
  40.         this.packer.ADD(R3PAPF_FILLX, 0, button);
  41.  
  42.         // tell the button where to find geometric objects
  43.         button.layer = this.layer;
  44.         return TRUE;
  45.     }
  46.     else
  47.         return FALSE;
  48. }
  49.     
  50. // Constructor
  51.  
  52. function myToolBar(titlebar, orientation, layer)
  53. {
  54.     if(arguments.length == 0)
  55.         return;
  56.     this.base = r3Window; 
  57.  
  58.     // let the super class to do its job
  59.     this.base(R3WGA_Left, 200,
  60.               R3WGA_Top, 150,
  61.               R3WA_ReportNewSize, TRUE,
  62.               R3WA_ReportCloseWindow, TRUE,
  63.               R3WA_Title, titlebar);
  64.  
  65.     // Create a packer for managing toolbar layout
  66.     this.packer = new r3Packer(0);
  67.     this.packer.SetOrientation(orientation);
  68.  
  69.     // layer to be manipulated by the tools in this tool bar
  70.     this.layer = layer;
  71.     
  72.     // method for inserting tool buttons
  73.     this.AddTool = mytbAddTool;
  74.  
  75.     // and give the packer to the window 
  76.     this.SetGmanager(this.packer);
  77. }
  78.  
  79. myToolBar.prototype=new r3Window;
  80.  
  81.